package org.xiyu.yee.datl.forge;

import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.xiyu.yee.datl.Datl;
import org.xiyu.yee.datl.forge.client.ForgeRenderEvents;
import org.xiyu.yee.datl.forge.client.KeyBindings;

@Mod(Datl.MOD_ID)
public final class DatlForge {
    public DatlForge(FMLJavaModLoadingContext context) {
        // Run our common setup.
        Datl.init();
        
        var modBusGroup = context.getModBusGroup();
        FMLClientSetupEvent.getBus(modBusGroup).addListener(this::clientSetup);
        
        // Register event listeners directly using EventBus 7 method
        var keyBindings = new KeyBindings();
        keyBindings.registerModEvents(modBusGroup);
        keyBindings.registerForgeEvents();
        
        // Register render events
        RenderPlayerEvent.Pre.BUS.addListener(ForgeRenderEvents::onRenderPlayerPre);
    }
    
    private void clientSetup(FMLClientSetupEvent event) {
        // Register individual event listeners as recommended by EventBus 7
        // No longer need to register here since we're using direct addListener
    }
}
